/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jBeatsUser.java
 *
 * Created on Nov 11, 2012, 5:19:41 PM
 */
package cs341.cs.uwosh.edu.jBeats;

/**
 *
 * @author haibut41
 */
public class jBeatsUser extends javax.swing.JFrame {
    FrameCreator FC = new FrameCreator();
    String user="";
    User[] userList = null;
    String[] usernameList;
    User currentUser;
    User selectedUser;
    String selectedUserName="";
    /** Creates new form jBeatsUser */
//    public jBeatsUser() {
//        initComponents();
//    }
    public jBeatsUser(User passedInUser, String playlistList[]){
        currentUser = passedInUser;
        selectedUserName = currentUser.getUserName();
        initComponents();
        
        userList = DatabaseInfo.getUserList();
        usernameList = new String[userList.length];
     
        for(int i=0;i<userList.length;i++){
            usernameList[i] = userList[i].getUserName();
        }
        
        userComboBox.setModel(new javax.swing.DefaultComboBoxModel(usernameList));
        
        usernameLabel2.setText(currentUser.getUserName());
        
        selectedUser = DatabaseInfo.getUserInfo(user);
        selectedUserName = selectedUser.getUserName();
        
        aboutMeTabbedPane.addTab("View",new aboutMeViewPanel(currentUser));
        aboutMeTabbedPane.addTab("Edit",new aboutMeEditPanel(currentUser));

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        userPanel2 = new javax.swing.JPanel();
        usernamePanel2 = new javax.swing.JPanel();
        staticUserLabel2 = new javax.swing.JLabel();
        usernameLabel2 = new javax.swing.JLabel();
        userComboBox = new javax.swing.JComboBox();
        songPanel = new javax.swing.JPanel();
        viewReviewsButton = new javax.swing.JButton();
        aboutMeTabbedPane = new javax.swing.JTabbedPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("jBeats");
        setName("Form"); // NOI18N
        setResizable(false);

        userPanel2.setBackground(new java.awt.Color(84, 131, 161));
        userPanel2.setMaximumSize(new java.awt.Dimension(550, 400));
        userPanel2.setMinimumSize(new java.awt.Dimension(550, 400));
        userPanel2.setName("userPanel"); // NOI18N
        userPanel2.setPreferredSize(new java.awt.Dimension(550, 500));

        usernamePanel2.setBackground(new java.awt.Color(84, 116, 191));
        usernamePanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 102, 0), null));
        usernamePanel2.setName("usernamePanel"); // NOI18N
        usernamePanel2.setPreferredSize(new java.awt.Dimension(391, 75));

        staticUserLabel2.setFont(new java.awt.Font("Dialog", 1, 18));
        staticUserLabel2.setText("User:");
        staticUserLabel2.setName("staticUserLabel"); // NOI18N

        usernameLabel2.setText("Jeremy");
        usernameLabel2.setName("usernameLabel"); // NOI18N

        userComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "user1", "user2", "user3", "user4", "user5", "user6", "user7" }));
        userComboBox.setName("userComboBox"); // NOI18N
        userComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                userComboBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout usernamePanel2Layout = new javax.swing.GroupLayout(usernamePanel2);
        usernamePanel2.setLayout(usernamePanel2Layout);
        usernamePanel2Layout.setHorizontalGroup(
            usernamePanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(usernamePanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(staticUserLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(usernameLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 87, Short.MAX_VALUE)
                .addComponent(userComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        usernamePanel2Layout.setVerticalGroup(
            usernamePanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(usernamePanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(usernamePanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(userComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(usernamePanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(staticUserLabel2)
                        .addComponent(usernameLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)))
                .addContainerGap())
        );

        songPanel.setBackground(new java.awt.Color(84, 116, 191));
        songPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 102, 0), null));
        songPanel.setMaximumSize(new java.awt.Dimension(398, 100));
        songPanel.setMinimumSize(new java.awt.Dimension(398, 100));
        songPanel.setName("songPanel"); // NOI18N

        viewReviewsButton.setText("View Reivews");
        viewReviewsButton.setName("viewReviewsButton"); // NOI18N
        viewReviewsButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                reviewsClicked(evt);
            }
        });

        javax.swing.GroupLayout songPanelLayout = new javax.swing.GroupLayout(songPanel);
        songPanel.setLayout(songPanelLayout);
        songPanelLayout.setHorizontalGroup(
            songPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(songPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(viewReviewsButton)
                .addContainerGap(172, Short.MAX_VALUE))
        );
        songPanelLayout.setVerticalGroup(
            songPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(songPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(viewReviewsButton)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        aboutMeTabbedPane.setName("aboutMeTabbedPane"); // NOI18N

        javax.swing.GroupLayout userPanel2Layout = new javax.swing.GroupLayout(userPanel2);
        userPanel2.setLayout(userPanel2Layout);
        userPanel2Layout.setHorizontalGroup(
            userPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(userPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(userPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(usernamePanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
                    .addComponent(aboutMeTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(songPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        userPanel2Layout.setVerticalGroup(
            userPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(userPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(usernamePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(aboutMeTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(songPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(userPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(userPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void reviewsClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_reviewsClicked
    jBeatsUserReviews frame = FC.createUserReviews(user);
    frame.setVisible(true);
    //userPlaylistList.set
}//GEN-LAST:event_reviewsClicked

private void userComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userComboBoxActionPerformed
 selectedUserName = (String)userComboBox.getSelectedItem();
    selectedUser = DatabaseInfo.getUserInfo(selectedUserName);
    usernameLabel2.setText(selectedUserName);
    aboutMeTabbedPane.removeAll();
    aboutMeTabbedPane.addTab("View",new aboutMeViewPanel(selectedUser));
    if(currentUser.getUserName().equals(selectedUserName)){
        aboutMeTabbedPane.addTab("Edit",new aboutMeEditPanel(selectedUser));
    }
}//GEN-LAST:event_userComboBoxActionPerformed
    
    public void setUsername(String name){
        usernameLabel2.setText(name);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane aboutMeTabbedPane;
    private javax.swing.JPanel songPanel;
    private javax.swing.JLabel staticUserLabel2;
    private javax.swing.JComboBox userComboBox;
    private javax.swing.JPanel userPanel2;
    private javax.swing.JLabel usernameLabel2;
    private javax.swing.JPanel usernamePanel2;
    private javax.swing.JButton viewReviewsButton;
    // End of variables declaration//GEN-END:variables
}
